﻿package mortal.game.view.arena.view
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.component.GCatogeryList.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.arena.data.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.item.*;
    import mortal.mvc.core.*;

    public class ArenaSettleCategoryHead extends CatogeryListHeadBase
    {
        private var _btnImg:GImageBitmap;
        private var _giftItem:BaseItem;
        private var _addBtn:GLoadedButton;
        private var _reduceBtn:GLoadedButton;
        private var _data:Object;
        private var _headData:ArenaWeekRuleData;
        public static var currSelHead:ArenaSettleCategoryHead;

        public function ArenaSettleCategoryHead()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.mouseEnabled = true;
            this.mouseChildren = true;
            this._btnImg = UIFactory.gImageBitmap("", 11, 0, this);
            this._giftItem = UICompomentPool.getUICompoment(BaseItem);
            this._giftItem.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg);
            this._giftItem.x = 20 - 5;
            this._giftItem.y = 6;
            this.addChild(this._giftItem);
            this._addBtn = UIFactory.gLoadedButton(ImagesConst.sup3_upSkin, 333 + 10, 15 + 2, 16, 16, this);
            this._reduceBtn = UIFactory.gLoadedButton(ImagesConst.sub3_upSkin, 332 + 11, 15 + 2, 16, 16, this);
            this._reduceBtn.visible = false;
            this.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            this.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            return;
        }// end function

        override public function updateData(param1:Object) : void
        {
            this._data = param1;
            var _loc_2:* = this._data as ArenaWeekRuleData;
            this._headData = _loc_2;
            if (_loc_2)
            {
                this._giftItem.itemCode = _loc_2.itemCode;
                if (_loc_2.type == EArenaRewardType._EArenaRewardTypeWeek)
                {
                    this._btnImg.imgUrl = "ArenaCurrReward_" + this._headData.rankMinValue;
                }
                if (_loc_2.type == EArenaRewardType._EArenaRewardTypeMouth)
                {
                    this._btnImg.imgUrl = "ArenaRegionReward_" + this._headData.rankMinValue;
                }
            }
            return;
        }// end function

        override public function set dataProvider(param1:DataProvider) : void
        {
            super.dataProvider = param1;
            return;
        }// end function

        override public function set isSelected(param1:Boolean) : void
        {
            return;
        }// end function

        override public function expand() : void
        {
            super.isExpanding = true;
            this.mouseEnabled = true;
            this.mouseChildren = true;
            this._addBtn.visible = false;
            this._reduceBtn.visible = true;
            var _loc_1:Object = {};
            _loc_1.index = this.index;
            _loc_1.headData = this._headData;
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaSettleExpand, _loc_1));
            return;
        }// end function

        override public function unexpand() : void
        {
            super.isExpanding = false;
            this._addBtn.visible = true;
            this._reduceBtn.visible = false;
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaSettleUnExpand, this.index));
            return;
        }// end function

        private function onOverHandler(event:MouseEvent) : void
        {
            CursorManager.showCursor(CursorManager.BUTTON);
            return;
        }// end function

        private function onOutHandler(event:MouseEvent) : void
        {
            CursorManager.hideFromButton();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._btnImg.dispose();
            this._btnImg = null;
            this._addBtn.dispose();
            this._addBtn = null;
            this._reduceBtn.dispose();
            this._reduceBtn = null;
            this._giftItem.dispose();
            this._giftItem = null;
            this._headData = null;
            return;
        }// end function

    }
}
